package owl2vowl;

import owl2vowl.converter.Converter;
import owl2vowl.converter.IRIConverter;
import owl2vowl.converter.InputStreamConverter;
import owl2vowl.converter.OntologyConverter;
import owl2vowl.export.types.BackupExporter;
import owl2vowl.export.types.FileExporter;
import java.io.File;
import java.io.InputStream;
import java.util.Collection;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLOntology;

public class Owl2Vowl {
	protected Converter converter;

	public Owl2Vowl(OWLOntology ontology) {
		this.converter = new OntologyConverter(ontology);
	}

	public Owl2Vowl(OWLOntology ontology, String ontologyIri) {
		this.converter = new OntologyConverter(ontology, ontologyIri);
	}

	public Owl2Vowl(IRI ontologyIri) {
		this.converter = new IRIConverter(ontologyIri);
	}

	public Owl2Vowl(IRI ontologyIri, Collection<IRI> dependencies) {
		this.converter = new IRIConverter(ontologyIri, dependencies);
	}

	public Owl2Vowl(InputStream ontology) {
		this.converter = new InputStreamConverter(ontology);
	}

	public Owl2Vowl(InputStream ontology, Collection<InputStream> dependencies) {
		this.converter = new InputStreamConverter(ontology, dependencies);
	}

	public String getJsonAsString() {
		BackupExporter exporter = new BackupExporter();
		try {
			this.converter.export(exporter);
		} catch (Exception e) {
			throw new IllegalStateException(e);
		}
		return exporter.getConvertedJson();
	}

	public void writeToFile(File file) {
		try {
			this.converter.export(new FileExporter(file));
		} catch (Exception e) {
			throw new IllegalStateException(e);
		}
	}
}
